<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<html>
<head>

<link href="<c:url value="/resources/homepage.css" />" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Backlog</title>
</head>
<script type="text/javascript">
	function checkBoxValidation1() {
		for (var i = 0; i < document.form1.check.length; i++) {
			if (document.form1.check[i].checked) {
				alert("Click OK to display your Story IDs list");
				return true;
			} else {
				alert("Please Select Your Story Id");
				return false;
				//location.href("ProjectEmp.jsp");
            }
			
		}
	}

	function EditStoryDetails(id, value) {
		window.open("EditStoryDetails.jsp?value=" + value + "&id=" + id,
				"Edit Story Details window", 'height=200px width=200px', false);
	}

	function msg4Close() {
		var res = confirm("Attention!"
				+ "\nIf you close this story then:"
				+ "\n* This story will be closed permanantly from the story backlog."
				+ "\n* This story's Estimate, Work To Be done (To do) and Actual Done fields will remain as it is."
				+ "\n* This story's status will also remain as it is."
				+ "\n\nAre you sure you want to close this story ?");
		if (res == true)
			;
		else {
			location.href("Backlog.jsp");
		}

	}

	function msg4Delete() {
		var res = confirm("Attention!"
				+ "\nIf you delete this story then:"
				+ "\n* This story will be deleted permanantly from the story backlog."
				+ "\n* This story's Estimate, Work To Be done (To do) and Actual Done fields will be cleared"
				+ "\n* This story's status will be changed to accepted."
				+ "\n\nAre you sure you want to delete this story ?");
		if (res == true)
			;
		else {
			location.href("Backlog.jsp");
		}

	}

	function getItems() {

	}
</script>
<body>
	<form name="form1" action="displayName"
		onsubmit="checkBoxValidation1()">
		<div id="wrapper">
			<!-- ============ HEADER SECTION ============== -->
			<div id="header">
				<div id="headerlogo"></div>
			</div>
			<!-- ============ NAVIGATION SECTION ============== -->
			<div id="menubar">

				<ul>
					<li><a href="Project">Projects</a></li>
					<li><a href="Backlog" ><span class="currentLink">Backlog</span></a></li>
					<li><a href="SprintPlanning">Sprint Planning</a></li>
					<li><a href="Storyboard1">Sprint Tracking</a></li>
					<li><a href="logout">Logout</a></li>
                    <li><a href="#">${username}</a></li>	
				</ul>
			</div>

			<!-- ============ MIDDLE SECTION ============== -->
			<div id="main">
				<div id="searchbar">
					
					<!-- 					<a href="#"><input type="button" value="Add Memembers" class="buttonStyle"style="margin-left:933px"/></a> -->
				</div>
				<div id="projectitle">

<!-- 					<h3>Project Title : Scrum</h3> -->
				</div>
				<div id="m1">

					<table>
						<tr>
							
							<td><input type="submit" value="MoveTo">
							<select name="sprint">
									<c:forEach var="sprint" items="${listSprint}">
										<option value=<c:out value="${sprint}"/>>
											<c:out value="${sprint}" />
										</option>
									</c:forEach>
							</select></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>

							<td><a href="CreateStory?project_id=<%=request.getParameter("project_id")%>"><input type="button"
									value="Create Story"> </a></td>
						</tr>
					</table>
				</div>


				<center>
					<sql:setDataSource var="myDS" driver="com.mysql.jdbc.Driver"
						url="jdbc:mysql://localhost:3306/springct" user="root"
						password="dhanashree" />
					<sql:query var="listUsers" dataSource="${myDS}">
select story_id, story_title,story_owner,priority_name,story_point from story,priority,storypoints where Story.priority_id=Priority.priority_id and Story.story_point_id=StoryPoints.story_point_id and project_id=<%=request.getParameter("project_id")%>;
		</sql:query>

					<div id="scroller">
						<table
							summary="This table holds data about the
          		stories in each project.I have included the story title
          		,the story id, the owner,estiamte of the story,priority
          		and edit drop down">
							<caption></caption>

							<tr>
								<th></th>
								<th>ID</th>
								<th>Story Title</th>
								<th>Owner</th>
								<th>Estimate</th>
								<th>Priority</th>
								<th>Edit</th>
								<th>Delete</th>
							</tr>


							<c:forEach var="user" items="${listUsers.rows}">
								<tr>
									<td><input type="checkbox" name="check"
										value="${user.story_id}"></td>
									<%-- 					<td><form:checkbox path="Iselected" value=<c:out value="${user.story_id}" />></form:checkbox></td> --%>
									<td><c:out value="${user.story_id}" /></td>
									<td><a
										href="StoryDetails?project_id=<%=request.getParameter("project_id")%>&sid=${user.story_id}"><c:out
												value="${user.story_title}" /></a></td>
									<td><c:out value="${user.story_owner}" /></td>
									<%-- 				<td><c:out value="${user.project_id}" /></td> --%>
									<td><c:out value="${user.story_point}" /></td>
									<td><c:out value="${user.priority_name}" /></td>

									<td><a href="editStory?project_id=<%=request.getParameter("project_id")%>&id=${user.story_id}">Edit</a>
										&nbsp;&nbsp;&nbsp;&nbsp;</td>
									<td><a href="deleteStory?id=${user.story_id}">Delete</a></td>
								</tr>
							</c:forEach>
						</table>
					</div>
				</center>
			</div>


			<div id="footer">
				<p>Copyright &copy; 2014 - All Rights Reserved - Spring
					Computing Pvt. Ltd.</p>
			</div>
		</div>
	</form>
</body>
</html>
